import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

let router_pc = [
  {
    path: '/',
    name: 'home',
    component: function (resolve) { require(['@/pc/pages/Home/Index'], resolve); }
  },
  {
    path: '/view/:cid',
    name: 'view',
    component: function (resolve) { require(['@/pc/pages/view/index'], resolve); }
  }, {
    path: '/:cate/:key',
    name: 'cate',
    component: function (resolve) { require(['@/pc/pages/CommonPage/Index'], resolve); }
  }

];

let router_mobile = [
  {
    path: '*',
    redirect: '/list/1'
  },
  {
    name: 'list',
    path: '/list/:cate',
    component: function (resolve) { require(['@/mobile/view/list'], resolve); }
  },
  {
    name: 'live',
    path: '/live/:uid',
    component: function (resolve) { require(['@/mobile/view/live_view'], resolve); }
  },
  {
    name: 'view',
    path: '/view/:id',
    component: function (resolve) { require(['@/mobile/view/view'], resolve); }
  }
];

let router = /(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent) ? router_mobile : router_pc;
export default new Router({ routes: router });
